<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('终端')" />
</head>
<body  class="gray-bg">
<div id="terminal" style="margin-left: 17px"></div>

<th:block th:include="include :: footer" />
<script>
    openTerminal( {
        operate:'connect',
        host: '[[${tServerInfo.host}]]',//IP
        port: '[[${tServerInfo.port}]]',//端口号
        username: '[[${tServerInfo.username}]]',//用户名
        password: '[[${tServerInfo.password}]]',//密码
    });
    function openTerminal(options){
        var client = new WSSHClient();
        var term = new Terminal({
            cols: 130,
            rows: 37,
            cursorBlink: true, // 光标闪烁
            cursorStyle: "block", // 光标样式  null | 'block' | 'underline' | 'bar'
            scrollback: 800, //回滚
            tabStopWidth: 15, //制表宽度
            screenKeys: true
        });

        term.on('data', function (data) {
            //键盘输入时的回调函数
            client.sendClientData(data);
        });
        term.open(document.getElementById('terminal'));
        //在页面上显示连接中...
        term.write('连接中...');
        //执行连接操作
        client.connect({
            onError: function (error) {
                //连接失败回调
                term.write('错误: ' + error + '\r\n');
            },
            onConnect: function () {
                //连接成功回调
                client.sendInitData(options);
            },
            onClose: function () {
                //连接关闭回调
                term.write("\r连接失败");
            },
            onData: function (data) {
                //收到数据时回调
                term.write(data);
            }
        });
    }
</script>
</body>
</html>